POV-Ray : Newsgroups : povray.general : Is it me or does rand(n) loop ? : Re: Is it me or does rand(n) loop ? Server Time
5 Aug 2024 02:23:23 EDT (-0400)
  Re: Is it me or does rand(n) loop ?  
From: BlackRose
Date: 18 Dec 2002 13:40:03
Message: <web.3e00bfe092e939f7f765b2b40@news.povray.org>
>Pseudorandom numbers do repeat, but the period is very large. If you are
>seeing repetition, you are probably using the rand() function wrong.
>Give the real code, trimmed down to the minimum required to demonstrate
>the problem, but check the documentation first.

    Well, I think I figured out what the problem was, but not exactly why it
was a problem. It seems that I was using the same variable to define which
stream I was using (#declare a = seed(15)) in the while loop, and then
using (#declare a = seed(40)) in a macro that I used within the while loop.
By changing one to a different variable name, I seem to have fixed the
problem...

    But now I'm confused. I apologize for bothering you about this, but the
documentation wasn't very clear/understandable to me, so I was wondering
when and to what extent reusing variable names is acceptable, and how that
relates to what is going on when I define and use macros and/or other
objects. (Did that make sense ?) Also, if I call the macro repeatedly, does
the random number generator i'm using within the macro get reset each time
? What exactly goes on with the different rand-number streams when I seed
it, and later call em ?

Thanks.
Vidya


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.